#!/usr/bin/env ruby
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
# frozen_string_literal: true

require 'set'
require_relative '../defconfig'

names = Set.new %w[
  ES_SUPER_USER
  ES_SUPER_PASSWORD
]

defaults = relevant_service_authentication(names)

docker_skip_rebuild 'kibana:7.11.1'

BASE_IMAGE_DICT = {
  'aarch64' => 'jamesgarside/kibana:7.11.1',
  'x86_64' => 'kibana:7.11.1'
}.freeze

BASE_IMAGE = BASE_IMAGE_DICT[%x(arch).chomp]

ARCH = %x(arch).chomp

system "docker build --no-cache -t kibana:7.11.1 --build-arg BASE_IMAGE=#{BASE_IMAGE} --build-arg USER=#{defaults['ES_SUPER_USER']} --build-arg PASSWORD=#{defaults['ES_SUPER_PASSWORD']} --build-arg ARCH=#{ARCH} ."

push_image_remote "kibana:7.11.1"
